<template>
  <div>
    <bScroll>
    <van-sidebar v-model="activeKey" class="item_menu" >
      <van-sidebar-item v-for="(item,index) in menuList" :key="index" @click="onChange(item.id)" :title="item.categoryname" />
    </van-sidebar>
     </bScroll>
  </div>
</template>
<script>
import bScroll from "@/components/bScroll/bScroll.vue";
export default {
    components: {
      bScroll
    },
  props:["menuList"],
  data() {
    return {
      activeKey: 0,
    };
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.onChange(this.$route.query.cid)
  },
  methods:{
    onChange(id){
      this.$router.push(`/index/home?cid=${id}`); 

    }
  },
  watch: {
    activeKey: function () {
      this.$nextTick(() => {
        this.$children[0].scroll.refresh();
      });
    },
     menuList: function () {
      this.$nextTick(() => {
        this.$children[0].scroll.refresh();
      });
    },
  },
};
</script>
<style scoped lang="less">
 @import '../../assets/css/index.less';
.item_menu{
    margin-top: 60*@vw;

}

</style>